package option;

import javafx.scene.input.DataFormat;

import javax.swing.*;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.util.Date;

public class Time implements Runnable {
    public boolean ifFinished=false;
    public boolean isStart=false;
    public static double i=0.014;
    private JLabel lab;
    public static double time=0;
    public Time(JLabel lab) {
        this.lab = lab;
    }

    @Override
    public void run() {
        isStart=true;
        time=0;
        DecimalFormat    df   = new DecimalFormat("######0.00");
        while (!ifFinished) {
            lab.setText(String.valueOf("已用时间："+df.format(time))+"秒");
            time=time+i;
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
